const {exec, escape} = require('../db/mysql')
// 获取角色信息
const getRoleList = async () => {
  const sql = `select *
               from role;`
  return await exec(sql)
}
// 修改角色信息
const updateRole = async ({id, role_desc}) => {
  id = escape(id)
  role_desc = escape(role_desc)
  const sql = `update role
               set role_desc = ${role_desc}
               where id = ${id}`
  return await exec(sql).then(data => {
    if (data.affectedRows > 0) {
      return true
    } else {
      return false
    }
  })
}

module.exports = {
  getRoleList,
  updateRole
}
